package org.effectiveframework.collection;

import java.util.ArrayList;
import java.util.Collection;

/**
 * This Utility class contains some utility method for collection
 *
 * @author Suraj Chhetry <surajchhetry@gmail.com.np>
 * @since 0.1
 * @version 0.1
 */
public class CollectionUtility {

    /**
     * *
     * Filter collection with given <param>filterString</param>
     *
     * @param collection that need to be filter
     * @param filterString string that help for filter the collection
     * @return Filtered Collection if <param>filterString</param> found
     * otherwise return empty collection
     */
    public static Collection<String> filter(Collection<String> collection, String filterString) {
        Collection<String> filteredList = new ArrayList();
        for (String s : collection) {
            if (s.contains(filterString)) {
                filteredList.add(s);
            }
        }
        return filteredList;
    }
}
